<?php
require_once 'Zend/View.php';
class Paging extends Zend_View{
    public static $number=10;
    public static  function totalPages($row){
        return (ceil($row/  Paging::$number));
        //return $row;
    }
    public function back($controller,$action,$page,$order,$method,$name=''){
           $result="";
             if($page>1){
             $result="<a class='nav' href=\"".$this->url(array('controller'=>$controller,
              'action'=>$action, 'page'=>1, 'order'=>$order,'method'=>$method,'name'=>$name))."\">
             <img src=\"".$this->baseUrl()."/images/icons/first.png\" alt=\"halaman pertama\" title=\"halaman pertama\"/>
             </a>
             <a class='nav' href=\"".$this->url(array('controller'=>$controller,
            'action'=>$action, 'page'=>$page-1, 'order'=>$order,'method'=>$method))."\">
             <img src=\"".$this->baseUrl()."/images/icons/back.png\" alt=\"halaman sebelumnya\" title=\"halaman sebelumnya\"/></a>&nbsp;";
             }
             return $result;
    }
        public function next($controller,$action,$totalPages,$page,$order,$method,$name=''){
           $result="";
             if($page!=$totalPages){
             $result="&nbsp;<a class='nav' href=\"".$this->url(array('controller'=>$controller,
              'action'=>$action, 'page'=>$page+1, 'order'=>$order,'method'=>$method))."\">
             <img src=\"".$this->baseUrl()."/images/icons/next.png\" alt=\"halaman berikutnya\" title=\"halaman berikutnya\"/>
             </a>
             <a class='nav' href=\"".$this->url(array('controller'=>$controller,
            'action'=>$action, 'page'=>$totalPages, 'order'=>$order,'method'=>$method,'name'=>$name))."\">
             <img src=\"".$this->baseUrl()."/images/icons/last.png\" alt=\"halaman terakhir\" title=\"halaman terakhir\"/></a>";
             }
             return $result;
    }

    public function current($controller,$action,$totalPages,$page,$order,$method,$name=''){
        $result="<select class='nav' onchange=\"javascript: window.location='".
                    $this->baseUrl()."/$controller/$action/page/' + this.options[this.selectedIndex].value + '/order/$order/method/$method".
                    "'\">\n";
        for($i=1; $i<=$totalPages; $i++){
            if($i==$page){
                $result .= "<option selected><b>$i</b></option>\n";
            }
            else{
                $result .= "<option><b>$i</b></option>\n";

            }
        }
        $result .= "</select>\n";
        return $result;
    }
}

?>
